package grafico;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.HeadlessException;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

import main.Contexto;

public class DlgEstrutura extends JDialog 
{
	static final long serialVersionUID = 1;

	private JEditorPane painel_estrutura; 

	public DlgEstrutura(String titulo) throws HeadlessException 
	{
		GerenteGUI gerente = GerenteGUI.instancia();
		Contexto contexto = Contexto.instancia();
		
		setTitle(titulo);
		setModal(true);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setSize(new Dimension(800,600));

		Container principal = getContentPane();
		principal.setLayout(new BorderLayout());
		principal.setBackground(Fabrica.branco);
		
		JPanel painel_superior = Fabrica.painelFundoAzul();
		painel_superior.setPreferredSize(new java.awt.Dimension(400, 70));
		principal.add(painel_superior,BorderLayout.NORTH);
		painel_superior.setBackground(Fabrica.background);
		painel_superior.setOpaque(true);
		
		JLabel titulo_janela = new JLabel(titulo);
		titulo_janela.setForeground(Fabrica.branco);
		titulo_janela.setFont(Fabrica.fonteGrande);
		painel_superior.add(titulo_janela);
		
		painel_estrutura = new JEditorPane();
		painel_estrutura.setEditable(false);
		painel_estrutura.setContentType("text/html");
		painel_estrutura.setBackground( gerente.toColor( contexto.getCorFundo() ) );		
		
        JScrollPane bottomScrollPane = new JScrollPane(painel_estrutura);
        bottomScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);   
		
		principal.add(bottomScrollPane,BorderLayout.CENTER);
		
		JPanel painel_inferior = Fabrica.painelFundoAzul();
		painel_inferior.setPreferredSize(new java.awt.Dimension(400, 50));
		FlowLayout flowCentered = new FlowLayout();
		flowCentered.setAlignment(FlowLayout.CENTER);
		painel_inferior.setLayout(flowCentered);
		principal.add(painel_inferior,BorderLayout.SOUTH);
		
		JButton fechar = Fabrica.botaoComImagem("fechar", "Fechar");
		painel_inferior.add(fechar);
	}

	public JEditorPane getTxtPane() 
	{
		return painel_estrutura;
	}
}
